def generate_mysql_insert_statement(keys, data, table_name):
    # 检查输入的键集合和字典集合是否为空
    if not keys or not data:
        return None

    # 构建插入语句的列部分
    columns = ", ".join(keys)

    # 构建插入语句的值部分
    values = []
    for entry in data:
        # 检查每个字典中是否包含与键集合对应的键，若不包含则跳过
        if not all(key in entry for key in keys):
            continue

        # 获取当前字典中与键集合对应的值，并处理为 MySQL 插入语句中的格式
        value_str = ", ".join(["'{}'".format(entry[key]) for key in keys])
        values.append("({})".format(value_str))

    # 构建完整的插入语句
    insert_statement = "INSERT INTO {} ({}) VALUES {};".format(table_name, columns, ", ".join(values))

    return insert_statement


# 示例用法
keys = ["name", "age", "gender"]
data = [
    {"name": "Alice", "age": 25, "gender": "female"},
    {"name": "Bob", "age": 30, "gender": "male"},
    {"name": "Charlie", "age": 35, "gender": "male"},
]
table_name = "example_table"

insert_statement = generate_mysql_insert_statement(keys, data, table_name)
print(insert_statement)